#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Purpose: Test object importer
# Created: 03/31/2009
# $Id $
# Copyright (c) 2008,2009 by University College London
# Authors:
# Didrik Pinte --<dpinte@dipole-consulting.com>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with HydroPlatform for details.

import unittest
import wx

import support
support.init_hydroplatform()

from hydroplatform.ui.object_importer import ProjectObjectList, ChooseProject
from hydroplatform.model.network import Project

class TestImportObjectType(unittest.TestCase):
    
    def setUp(self):
        self.session = support.get_dbsession()
        support.load_sample_network1(self.session)
        self.project = Project("test3", "desc", None)
        self.session.add(self.project)
        self.session.commit()
        
    def test_interface(self):
        t = ChooseProject(session = self.session,
                          project = self.project)
        if t.configure_traits(view=t.get_view(), kind="modal") is True:
            p = ProjectObjectList(project = self.project,
                                  session = self.session,
                                  from_projectid = t.projectid)
            if p.configure_traits(view=p.get_view(), kind="modal") is True:
                # FIXME : this is a buggy test as it depends on the user input ...
                self.assertEqual(len(self.project.nodetypes), 5)
        
if __name__=='__main__':
    unittest.main()